/**
 * @author mili
 */

var incidents,features;

function getIncidents(arrayOfFiles){
	incidents = [];
	features = [];
	for(var i = 0; i < arrayOfFiles.length; i++){
		if(i == 0){
			getIncidentsFromJsonFile(arrayOfFiles[i],false);
		}else{
			getIncidentsFromJsonFile(arrayOfFiles[i],true);
		}
	}
	return incidents;
}

function getIncidentsFromJsonFile(jsonFile,testNew){
	var jsonObj = parseJSON(incident_url + jsonFile);
	var features = getFeatures(jsonObj);
	for(var i = 0; i < features.length; i++){
		var property = getProperties(features[i]);
		if(testNew){
			if(isNewIncident(property)){
				makeNewIncident(features[i]);
			}else{
				// do nothing
			}
		}else{
			makeNewIncident(features[i]);
		}
	}
}

function makeNewIncident(feature){
	features.push(feature);
	incidents.push(getLatLng(feature));
}
